package com.xuelang.pipeline.artifact.client.resource;

import com.xuelang.pipeline.artifact.client.common.request.PageParam;
import com.xuelang.pipeline.artifact.client.common.result.ApiResult;
import com.xuelang.pipeline.artifact.client.common.result.PageRecord;
import com.xuelang.pipeline.artifact.client.resource.dto.ArtifactRoleUserDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.ArtifactUserDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.ArtifactUserQuery;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 仓库用户服务API
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
public interface IArtifactUserService {

    /**
     * 查询仓库用户列表(有过滤条件，可以分页)
     *
     * @param dtoPageParam 查询条件
     * @return
     */
    @PostMapping(value = "/pageList", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<ArtifactUserDTO>> pageArtifactUserList(@RequestBody @Valid PageParam<ArtifactUserQuery> dtoPageParam);

    /**
     * 查询仓库用户列表(有过滤条件)
     *
     * @param artifactUserQuery 查询条件
     * @return
     */
    @PostMapping(value = "/list", produces = "application/json;charset=utf-8")
    ApiResult<List<ArtifactUserDTO>> conditionalArtifactUserList(@RequestBody @Valid ArtifactUserQuery artifactUserQuery);

    /**
     * 新增仓库用户
     *
     * @param artifactUserDTO 仓库用户DTO
     * @return
     */
    @PostMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> addArtifactUser(@RequestBody @Valid ArtifactUserDTO artifactUserDTO);

    /**
     * 更新仓库用户
     *
     * @param artifactUserDTO 仓库用户DTO
     * @return
     */
    @PutMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> updateArtifactUser(@RequestBody @Valid ArtifactUserDTO artifactUserDTO);

    /**
     * 删除仓库用户
     *
     * @param id 仓库用户UUID
     * @return
     */
    @DeleteMapping(value = "/{id}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> deleteArtifactUser(@PathVariable("id") String id);
    /**
     * 查询仓库用户
     *
     * @param id 仓库用户UUID
     * @return
     */
    @GetMapping(value = "/{id}", produces = "application/json;charset=utf-8")
    ApiResult<ArtifactUserDTO> queryArtifactUser(@PathVariable("id") String id);

    /**
     * 更新仓库下角色的用户信息
     *
     * @param artifactRoleUserDTO 查询条件
     * @return
     */
    @PostMapping(value = "/update/role/user", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> updateArtifactRoleUser(@RequestBody @Valid ArtifactRoleUserDTO artifactRoleUserDTO);

    /**
     * 查询仓库下角色的用户信息
     *
     * @param artifactUuid
     * @return
     */
    @GetMapping(value = "/query/role/user/{artifactUuid}", produces = "application/json;charset=utf-8")
    ApiResult<ArtifactRoleUserDTO> queryArtifactRoleUser(@PathVariable("artifactUuid") String artifactUuid);
}
